#include "FindNode.h"
#include<iostream>
using namespace std;

FindNode::~FindNode(){

}
//初始化链表
FindNode::FindNode(int val){
    head=new Node();
    head->next=NULL;
    head->val=val;
    //方便起见,size从1计数
    size=1;

};
//寻找倒数k元素
Node* FindNode::FindNodeByReverseK(int k){
    Node *currentNode=head;
    if (k>size)
    {
        cout<<"The k more than size"<<endl;
        /* code */
    }
    else
    {
        int idx=size-k;
        while (idx>0)
        {
            currentNode=currentNode->next;
            idx--;
            /* code */
        }
        
        
    }
    
    
}
//获取当前查找链表的大小
int FindNode::getListLength(){
    return size;
}

//程序简单起见，默认插队尾。。 
 
void FindNode::insertNode(int val){
    Node *currentNode=head;
    while (currentNode->next!=NULL)
    {
        currentNode=currentNode->next; 
        /* code */
    }

    Node *newNode=new Node();
    newNode->val=val;
    newNode->next=NULL;
    currentNode->next=newNode;
    size++;
}